package net.zjitc.servlet;

import net.zjitc.domain.product;
import net.zjitc.domain.user;
import net.zjitc.service.ProductService;
import net.zjitc.service.UserService;
import net.zjitc.service.impl.ProductServiceImpl;
import net.zjitc.service.impl.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

/**
 * @Author admin
 * @Date 2019/3/6 11:13
 */
@WebServlet(name = "CheckServlet",urlPatterns = "/check")
public class CheckServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String username = request.getParameter("username");
        UserService service = new UserServiceImpl();
        user user = service.register(username);
        if ( user!= null )
        {
            //println错误
            response.getWriter().print(false);
        }else {
            response.getWriter().print(true);
        }
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}
